{% extends "template/page.html" %}

{% block title %}{{ title }}{% endblock %}
{% block page_title %}{{ title }}{% endblock %}

{% block setting %}active{% endblock %}

{% block body%}
<div class="row">
          <div class="col-lg-12">
            <div class="card">
              <ul class="nav nav-tabs page-tabs">
                <li class="active"> <a href="#!">管理员信息</a> </li>
              </ul>
              <div class="tab-content">
                <div class="tab-pane active">
                  <form method="post" name="edit-form" class="edit-form">
                    <div class="form-group">
                      <label>后台账号</label>
                      <input class="form-control" type="text" name="username" value="{{ username }}">
                      </div>

                    <div class="form-group">
                      <label>后台密码</label>
                      <input class="form-control" type="password" name="password" value="{{ password }}" placeholder="">
                    </div>
                    <div class="form-group">
                      <label>昵称</label>
                      <input class="form-control" name="nickname" value="{{ nickname }}" placeholder="">
                    </div>
                    <div class="form-group">
                      <label>头像</label>
                      <input class="form-control" name="avatar" value="{{ avatar }}" placeholder="">
                    </div>
                    <div class="form-group">
                      <button type="submit" class="btn btn-primary m-r-5">保 存</button>
                    </div>
                  </form>
                </div>
              </div>

            </div>
          </div>
        </div>
{% endblock %}

{% block script %}
<script>
    $(document).ready(function(){
        $("form").submit(function(event){
            event.preventDefault();
            lightyear.loading('show');
            $.ajax({
              url: "/api/changePassword",
              type: "POST",
              data: $(this).serialize(),
              success: function(data){
                if(data.code == 200){
                  lightyear.notify(data.msg, 'success', 2000);
                  lightyear.loading('hide');
                } else {
                  lightyear.notify(data.msg, 'danger', 2000);
                  lightyear.loading('hide');
                }
              },
              error: function(){
                lightyear.notify('网络错误', 'danger', 2000);
                lightyear.loading('hide');
              }
            });
        });
    });
</script>
{% endblock %}
